import {Pipe, PipeTransform} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';

@Pipe({
  name: 'bySanitizerPipe'
})
export class BySanitizerPipe implements PipeTransform {
  constructor(private sanitizer: DomSanitizer) {
  }

  transform(content, type = 'url') {
    if (type === 'html') {
      return this.sanitizer.bypassSecurityTrustHtml(content);
    } else if (type === 'url') {
      return this.sanitizer.bypassSecurityTrustResourceUrl(content);
    }
    return this.sanitizer.bypassSecurityTrustResourceUrl(content);
  }
}
